﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>文件类型管理添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="weadmin-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="FTName" class="layui-form-label">
                    <span class="we-red">*</span>类型名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="FTName" name="FTName" lay-verify="required|nikename" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="FTDescribe" class="layui-form-label">
                    <span class="we-red"></span>类型描述
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="FTDescribe" name="FTDescribe" lay-verify="nikename" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="add">确定</button>
                </div>
            </div>
        </form>
    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>

    <script>
        //layui.extend({
        //    admin: '{/}../../../static/js/admin'
        //});
        layui.use(['form', 'jquery', 'layer', 'laydate'], function () {
            var form = layui.form,
                $ = layui.jquery,
                //util = layui.util,
                //admin = layui.admin,
                layer = layui.layer,
                laydate = layui.laydate;
            //表单默认值，方便测试，后续删除
            //var sj = Math.round(Math.random() * 1000);
            //$("#EmpID").val("EmpId" + sj);
            //$("#EmpName").val("EmpName" + sj);
            //$("#EmpPwd").val("123456");
            //$("#ReEmpPwd").val("123456");
            //$("#EmpAge").val("26");
            //$("#EmpBirthday").val("2018-01-05");
            //$("#EmpAddress").val("EmpAddress" + sj);
            //$("#EmpTel").val("EmpTel" + sj);
            //$("#EmpPhone").val("13535353535");
            //$("#EmpDescription").val("EmpDescription" + sj);
            //cjh
            //监听提交
            form.on('submit(add)', function (formdata) {
                $.ajax({
                    url: ApiUrl + "TrainFileType/Add",
                    type: 'post',
                    dataType: 'json',
                    cache: false,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: formdata.field,
                    success: function (data) {
                        console.log(data)
                        if (data.StatusCode == 200) {
                            layer.alert("增加成功", { icon: 6 }, function (index) {
                                parent.layer.closeAll();
                            })
                        }
                        else if (data.StatusCode == 403) {
                            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
                return false;
            });

        });
    </script>
</body>
</html>